<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Scenario Programming</title>
</head>

<body text="#FFFFFF" bgcolor="#000000" style="font-family: Verdana; font-size: 10pt" link="#00FFFF" vlink="#00FFFF" alink="#00FFFF">

<p><font size="3"><b>Programming a Custom Scenario</b></font></p>
<p>You can program your own custom <a href="Scenarios.htm">Scenarios</a> in 
Solar Vengeance using the C# programming language.&nbsp; You can write Scenario 
code in any text editor, but it is more productive to write the code in a full 
fledged development environment like Microsoft Visual Studio or SharpDevelop.&nbsp; 
In your Scenario programming, you can leverage the complete power of the .NET 
framework class library.&nbsp; The Scenario code is automatically compiled 
within the game, so executes very quickly during the game.</p>
<p>A Scenario is a .NET class that derives from the Scenario base class.&nbsp; 
If you are using a development environment for editing, you should add a reference to the SCG.SolarVengeance.Engine 
assembly.&nbsp; Create a new .NET class, and make &quot;Scenario&quot; the base class.&nbsp; 
At a minimum you will then need to override the Description property and the 
BuildScenario method, described below.&nbsp; You can override other properties 
and methods to customize the Scenario further and introduce dynamic behaviors.</p>
<p>You should give the Scenario class name the same name as the source 
code file that you create.&nbsp; For example, if you save the Scenario in a file 
called MyScenario.cs, the Scenario class name should be &quot;MyScenario&quot;.</p>
<p><b><font color="#FFFF00">Scenario Properties</font></b></p>
<p>The Scenario base class contains a number of properties you can override in 
your derived class.&nbsp; Overriding these properties changes some aspect of the 
Scenario.</p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>bool</b></font><font SIZE="2"> AssignCapitals<br>
The default value of this property is true, and instructs SV5 to assign Capitals 
to Players if they are not assigned by the time the Scenario is created.&nbsp; 
If you override this to return false, Players will not have Capitals unless you assign them 
explicitly in the BuildScenario method.&nbsp; You may need to do this, for 
example, if your Scenario creates fleets of StarShips only, with no StarSystems.&nbsp; 
When writing a Scenario such as this, you should code your own Victory Conditions in the VictoryReached method.</p>
</font>
<p><font SIZE="2" COLOR="#00FFFF"><b>public</b> <b>virtual</b> <b>string</b></font><font SIZE="2"> 
Author<br>
Override this property to return your name, or Star Lord name.&nbsp; You want to 
get proper credit for your creation!</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>int</b></font><font SIZE="2"> CapitalValue<br>
Override this property to specify a default value for players Capital 
<a href="StarSystems.htm">StarSystems</a>.&nbsp; The default value is 20, and 
this is also the maximum allowed.&nbsp; Players can modify this value manually 
when they select a Scenario to play.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>int</b></font><font SIZE="2"> DefaultResources<br>
Override this property to specify the amount of Resources that 
players' Capital <a href="StarSystems.htm">StarSystems</a> should get at the 
start of the game.&nbsp; The default value is 100 and the maximum is 1,000.&nbsp; 
Players can modify this value manually when they select a Scenario to play.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>bool</b></font><font SIZE="2"> 
CapitalElimination<br>
The default value of this property is true.&nbsp; If you override and set to 
false, then a player is not eliminated from the game when their Capital is 
conquered.&nbsp; If you do this, be sure to specify your own custom Victory 
Conditions by overriding the VictoryReached method.</p>
</font>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>int</b></font><font SIZE="2"> CapitalShields<br>
Override this property to change the number of Shields that players' 
Capital <a href="StarSystems.htm">StarSystems</a> start with from the default value of 10.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>int</b></font><font SIZE="2"> CapitalScanners<br>
Override this property to change the number of Scanners that players' 
Capital <a href="StarSystems.htm">StarSystems</a> start with from the default value of 10.</p>
</font><font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>abstract</b> <b>string</b></font><font SIZE="2"><font color="#00FFFF">
</font>Description<br>
Override this property to return a description of the Scenario that appears when 
it selected from the list.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> Size</font><font SIZE="2"> MapSize<br>
Override this property to set a map size other than the standard 
100x100.</p>
</font><font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>int</b></font><font SIZE="2"><font color="#00FFFF">
</font>MaxPlayers<br>
Override this property to change the maximum number of players that 
the Scenario can accommodate.&nbsp; The default value is 10.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> PlayModeRecommendation</font><font SIZE="2"> 
Recommendation<br>
Override this property if your Scenario is intended to be played only in solo 
mode, or multiplayer mode.&nbsp; Return </font><font SIZE="2" COLOR="#00FFFF">
PlayModeRecommendation</font><font SIZE="2">.<font color="#00FFFF">Solo</font> 
or </font><font SIZE="2" COLOR="#00FFFF">PlayModeRecommendation</font><font SIZE="2">.<font color="#00FFFF">MultiPlayer</font>.&nbsp; 
If you return one of these values, a message appears above the Scenario preview 
when players select the Scenario before a game.</font></p>
<p><b><font color="#FFFF00">Adding/Disallowing StarShip Types</font></b></p>
<p>You can control what <a href="StarShips.htm">StarShip</a> types are added and disallowed in your Scenario 
by using the two methods below.&nbsp; Create a List&lt;StarShipType&gt; 
and return it in these properties.&nbsp; StarShipType 
is an enum that represents all of the available StarShip types.</p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> IList&lt;StarShipType</font><font SIZE="2"><font color="#00FFFF">&gt;</font> 
AddedStarShipTypes<br>
Return a list of StarShipTypes that should be automatically added to each 
player's available list at the start of the game.</p>
</font><font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> IList&lt;StarShipType</font><font SIZE="2"><font color="#00FFFF">&gt;</font> 
DisallowStarShipTypes<br>
Return the StarShipTypes that should not be allowed in this Scenario.&nbsp; 
These StarShipTypes will be removed from players' selections at the start of 
the game.</font></p>
<p><b><font color="#FFFF00">The BuildScenario Method</font></b></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>abstract</b> <b>void</b></font><font SIZE="2"> BuildScenario(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
numPlayers, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
capitalValues, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
startingResources);<br>
</font>You must override the BuildScenario method and provide the logic 
that actually creates the Scenario, using the various methods in the 
Scenario API described below.</p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>void</b></font><font SIZE="2"><font color="#00FFFF">
</font>NonHostInitialize()<br>
The NonHostInitialize method is called in MultiPlayer games by the other players 
who have joined the game.&nbsp; Implement this method to set up any data 
structures or perform initialization that was done in the BuildScenario method 
call.&nbsp; Because only the Host player calls BuildScenario, you can use 
NonHostInitialize to ensure that Clients are up to date with required 
information.&nbsp; You can pass information to Clients by using the ScenarioInfo 
properties of the SVGame, StarShip, and StarSystem classes (explained more in 
the <a href="Dynamic%20Scenarios.htm">Dynamic Scenario</a> topic.)</p>
</font>
<p><font color="#FFFF00"><b>The Scenario API</b></font></p>
<p>The Scenario API includes a set of methods that you can use in your 
implementation of BuildScenario to create 
<a href="StarSystems.htm">StarSystems</a>, <a href="StarShips.htm">StarShips</a>, 
<a href="Interstellar%20Empires.htm">Nebula</a>, and anything else you need to place in the 
Scenario.&nbsp; For more advanced control, it might be required to access the SVGame object provided by the Game property 
(see below).&nbsp; 
But for most applications you should be able to achieve what you need with the 
Scenario API.</p>
<p>One of the best ways to learn how to build Scenarios is to examine the code 
for the Scenarios provided in the SV5 install.&nbsp; Start with simple Scenarios 
like Classic.cs, DoubleCluster.cs and MirrorImage.cs, then move your way up to 
the more advanced Scenarios like PsiWars.cs and CollectTheScientists.cs.</p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> CreateBlackHole(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> radius)<br>
Creates a Black Hole at the specified location, with the specified radius.&nbsp; 
The radius indicates how close StarShips must be to begin to be pulled into the 
Black Hole.</p>
</font>
<font SIZE="2" COLOR="#C0C0C0"><b>
<p>protected</b> <b>void</b> CreateNebula(<b>int</b> 
x, <b>int</b> y, <b>int</b> numArms, <b>int</b></font><font SIZE="2"><font color="#C0C0C0"> numCells)<br>
</font>This method is deprecated.&nbsp; Use CreateTerrain instead to create a 
variety of possible terrains, including Nebula.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> CreatePulsar(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y)<br>
Creates a Pulsar at the specified coordinates.</p>
</font>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> CreateStarCluster(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
numStarSystems, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x1, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y1,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> x2,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y2,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> radius,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> density)<br>
Call this method to produce a <a href="StarSystems.htm">StarSystem</a> cluster in the Scenario.&nbsp; The 
cluster will create StarSystems along a line specified by the coordinates x1,y1 
to x2,y2.&nbsp; The coordinates pairs can both be the same to create a purely 
globular cluster.&nbsp; The radius parameter determines the maximum distance 
that StarSystems will be produced away from the line/point.&nbsp; The density 
parameter determines how many times the generated StarSystem positions are 
averaged together, leading to more highly dense clusters as the value increases.&nbsp; 
StarSystem Values, Resources, Shields, and Scanners are all randomized.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> StarShip</font><font SIZE="2"> CreateStarShip(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y,
</font><font SIZE="2" COLOR="#00FFFF">Player</font><font SIZE="2"> owner, </font>
<font SIZE="2" COLOR="#00FFFF">StarShipType</font><font SIZE="2"> shipType,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> engines,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> extra,
</font><font SIZE="2" COLOR="#00FFFF"><b>bool</b></font><font SIZE="2"> cloaked)<br>
Creates a <a href="StarShips.htm">StarShip</a> at the specified location, using the parameters to determine 
its StarShip type, Engines, and Primary System values (the &quot;extra&quot; parameter), 
as well as whether or not it should be cloaked.&nbsp; The Player property 
indicates the owner of the StarShip, and is an object of the Player class.&nbsp; You can access the Player 
objects via the Players property of the Game property.&nbsp; The
Players property is a List&lt;Player&gt;.</font></p>
<p>Example:</p>
<p>Player p = Game.Players[0];<br>
CreateStarShip(50, 50, p, StarShipType.WarShip, 20, 10, true);</p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b></font><font SIZE="2"> </font><font SIZE="2" COLOR="#00FFFF">
StarSystem</font><font SIZE="2"> CreateStarSystem(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y)<br>
Creates a StarSystem at the specified location, using the same randomized Value, 
Resources, Shields, and Scanners for StarSystems that are created with 
CreateStarCluster.</p>
</font>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> StarSystem</font><font SIZE="2"> CreateStarSystem(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> value,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> shields,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> scanners,
</font><font SIZE="2" COLOR="#00FFFF"><b>double</b></font><font SIZE="2"> 
resources)<br>
Creates a single <a href="StarSystems.htm">StarSystem</a> at the location specified in x,y.&nbsp; Specify the properties of the StarSystem in the 
parameters.&nbsp; To perform further modification of the StarSystem, set the 
properties in the StarSystem object that is returned by this method.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> CreateTerrain(</font><font SIZE="2" COLOR="#00FFFF">TerrainType</font><font SIZE="2"> 
tt, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> x,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y, </font>
<font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> numArms, </font>
<font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> numCells)<br>
Creates a random span of terrain of the specified type.&nbsp; The current 
possible values of TerrainType are Clear and Nebula.&nbsp; The terrain mass is 
centered on the coordinates specified in x and y, and is randomly generated by 
moving a virtual pen around the map in random directions, for a number of times 
equal to the numCells parameter.&nbsp; The process is repeated, starting back at 
the origin, for a number of times specified by the numArms parameter.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b></font><font SIZE="2"><font color="#00FFFF"> <b>ScenarioImage</b></font> CreateTerrainImage(</font><font SIZE="2" COLOR="#00FFFF">TerrainType</font><font SIZE="2"> 
tt, </font><font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> 
imageFileName, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y,
</font><font SIZE="2" COLOR="#00FFFF"><b>double</b></font><font SIZE="2"> alpha)<br>
Allows you to provide custom background images that will be displayed on the 
map, and optionally converted to  terrain elements.&nbsp; Image files that are 
used as backgrounds must be in the &quot;Scenarios&quot; folder under the main SV5 install 
folder.&nbsp; Provide the name of the image file, with extension, in the 
imageFileName property.&nbsp; The x and y properties determine the coordinates 
where the image will be drawn on the map, specified in game map coordinates.&nbsp; 
If the tt property contains a terrain other than &quot;Clear&quot;, the image will be 
examined cell by cell.&nbsp; A cell is a 30x30 pixel block that maps to a 
coordinate on the playing map.&nbsp; If a cell contains any non-black pixels, 
the corresponding map cell will be set to the specified terrain (currently the 
only terrain available is Nebula.)&nbsp; The alpha property specifies a 
transparency level to apply when rendering the image.&nbsp; Specify 1.0 for a 
fully opaque image.&nbsp; Values less that 1.0 indicate levels of transparency 
to apply to the image, which can lead to more pleasing effects when rendering 
cosmic images to the map.&nbsp; The method returns an instance of a 
ScenarioImage object, which you normally do not need to worry about.&nbsp; 
However, you can manipulate the Visible property of this object to show/hide 
images on the map.&nbsp; You might save this object to a local variable and 
manipulate it from the CheckVictory method, for example.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> UDO</font><font SIZE="2"> CreateUDO(</font><font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> 
name, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> x,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y, </font>
<font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> imageName,
</font><font SIZE="2" COLOR="#00FFFF"><b>bool</b></font><font SIZE="2"> 
autoPickUp)<br>
Creates a UDO (User-Defined Object).&nbsp; See the topic on <a href="UDOs.htm">
UDOs</a> for more information.</p>
</font><font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> CreateWormhole(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x1, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y1,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> x2,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y2)<br>
This method creates a <a href="Interstellar%20Empires.htm">Wormhole</a> at location x1,y1, with a destination point at 
x2,y2.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> TerrainType</font><font SIZE="2"> GetTerrain(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y)<br>
Returns the terrain at the specified location.&nbsp;
TerrainType is an enum with possible values of
Clear and <a href="Interstellar%20Empires.htm">Nebula</a>.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> SetTerrain(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y,
</font><font SIZE="2" COLOR="#00FFFF">TerrainType</font><font SIZE="2"> terrain)<br>
Allows you to set the terrain on a coordinate by coordinate basis.</font></p>
<p><b><font color="#FFFF00">Assigning Capitals</font></b></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>bool</b></font><font SIZE="2"><font color="#00FFFF"> </font>
AssignCapital(</font><font SIZE="2" COLOR="#00FFFF">Player</font><font SIZE="2"> 
player, </font><font SIZE="2" COLOR="#00FFFF">Rectangle</font><font SIZE="2"> 
area)<br>
You can call this method after all of your <a href="StarSystems.htm">StarSystems</a> are created to attempt to 
assign a Capital to a Player within an area of the map specified in the area 
parameter.&nbsp; This method is useful for assigning Capitals to alternating 
sides of the map, for example.&nbsp; See DoubleCluster.cs for an example of this 
technique.</font></p>
<p>You can also assign capitals manually by manipulating the SVGame object 
exposed to you via the Game property.&nbsp; To assign 
a Capital, set the Player.Capital property to the desired StarSystem.&nbsp; See 
MirrorImage.cs for an example of explicitly assigning Player Capitals.</p>
<p>//example - assign the first StarSystems we created as Capitals to the 
Players in the game<br>
int n = 0;<br>
foreach(Player p in Game.Players)<br>
&nbsp;&nbsp; p.Capital = Game.StarSystems[n++];</p>
<p>If you fail to set Capitals in your Scenario code, do not worry.&nbsp; SV5 
does it automatically before the game starts, unless you disabled this by 
returning false when overriding the AssignCapitals Scenario property.</p>
<p><b><font color="#FFFF00">Miscellaneous Methods of the Scenario Base Class</font></b></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>double</b></font><font SIZE="2"> Distance(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x1, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y1,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> x2,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y2)<br>
Calculates the accurate distance between two points.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>int</b></font><font SIZE="2"> DistanceQuick(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
x1, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y1,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> x2,
</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> y2)<br>
Returns a quick calculation of distance between two points by adding the 
absolute values of the differences of the x and y coordinates.&nbsp; The 
performance of this method is much faster than the Distance method.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>void</b></font><font SIZE="2"> Initialize()<br>
SV5 calls the Initialize method before the game starts.&nbsp; The Initialize 
method is called in the Scenario object of all game participants in a 
MultiPlayer game.&nbsp; For the game host, it is called prior to BuildScenario, 
and for clients, prior to PostLoadInitialize.</font></p>
<p>
<font SIZE="2" COLOR="#00FFFF"><b>
protected</b> <b>int</b></font><font SIZE="2"> Random(</font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
from, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> to)<br>
Returns a random integer within a range of values, inclusive of the from and to 
values.&nbsp; You can also access a static instance of the Math.Random class in 
the SVGame class via the RND static property.</font></p>
<p><b><font color="#FFFF00">Custom Victory Conditions</font></b></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>bool</b></font><font SIZE="2"> VictoryReached()<br>
If you override this method, you can have your Scenario specify its own specific 
victory conditions.&nbsp; This method is called after each 
<a href="Impulses%20and%20Movement.htm">Impulse</a> is processed 
in Solar Vengeance.&nbsp; In this method you can examine the current game state 
by accessing the Game property, which is an instance of the SVGame class and contains the current state of the 
game.&nbsp; You can examine the game state by reading properties in the Game 
object, but do not  change any values here.&nbsp; If you do, the changes will not 
be communicated to other players in a MultiPlayer game.</font></p>
<p><font SIZE="2">When implementing this method, if you have determined that your custom victory conditions have 
been reached, you should set the Victor property to 
true for each Player object that has met the 
conditions, and then return true from this method.&nbsp; If your custom victory conditions have not been met, and you 
want to keep the default victory condition of Player elimination, be sure to 
return base.VictoryReached in your implementation.</font></p>
<p>In MultiPlayer games, VictoryReached is executed in the Scenario object of 
the game &quot;host&quot; only, not the game &quot;clients&quot;.&nbsp; If the host determines that 
victory has been achieved, by returning true here, the information is 
automatically passed to the clients by SV.</p>
<p><font SIZE="2">See the Scenarios XMarksTheSpot.cs, RingNebula.cs, and 
CollectTheScientists.cs for some examples of how to 
code  custom Victory Conditions.</font></p>
<p><b><font SIZE="2" color="#FFFF00">Persisting Information in Scenarios</font></b></p>
<p><font SIZE="2">When a game is saved and reloaded, the BuildScenario method of 
the Scenario object is not called again.&nbsp; Rather, all of the game 
information is loaded from the save game file.&nbsp; Likewise, clients in 
MultiPlayer games do not have their BuildScenario called either.</font></p>
<p><font SIZE="2">The Scenario framework provides a mechanism to persist data in 
the Scenario and to communicate it to clients in a MultiPlayer game.&nbsp; This 
is accomplished using the GetValue and SetValue methods, and the 
PostLoadInitialize method.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>void</b></font><font SIZE="2"> SetValue(</font><font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> 
tag, </font><font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> 
value)<br>
Call SetValue to save a value to the Scenario's persistent storage.&nbsp; The 
value will be reloaded when a saved game is restored, and also communicated to 
clients in a MultiPlayer game.&nbsp; During a game, you can call SetValue during 
the ProcessImpulse method, and the values you set will automatically be sent to 
clients in the game.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> <b>string</b></font><font SIZE="2"> GetValue(</font><font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> 
tag)<br>
Call GetValue to read a value that was previously stored by SetValue.</font></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>void</b></font><font SIZE="2"> 
PostLoadInitialize()<br>
SV5 calls this method after a saved game loads and all of the persistent data 
was reloaded into the Scenario.&nbsp; SV5 also calls this method for clients in 
a MultiPlayer game.&nbsp; Override this call to read persistent data and make 
any required initialization.</font></p>
<p><font SIZE="2">For example, the ChaosCluster Scenario uses this method to 
communicate the chance that a random chaos event will occur in the Scenario.&nbsp; 
The sequence of events is as follows:</font></p>
<ol>
  <li><font SIZE="2">The host player's BuildScenario method is called, and the 
  chance that a chaos change will occur is calculated and stored in an internal 
  double variable.</font></li>
  <li><font SIZE="2">The BuildScenario code uses SetValue to store this value in 
  persistent storage.</font></li>
  <li><font SIZE="2">Clients that join the game have their PostLoadInitialize 
  methods called.</font></li>
  <li><font SIZE="2">In this implementation, the persistent value is read by 
  GetValue, decoded, and stored in the Scenario's internal double variable.</font></li>
</ol>
<p><font SIZE="2">In this way, required information is kept in synch between all 
participants in the game.</p>
<p><b><font color="#FFFF00">Scenario Parameters</font></b></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>protected</b> ScenarioParameter</font><font SIZE="2"> CreateParameter(</font><font SIZE="2" COLOR="#00FFFF"><b>string</b></font><font SIZE="2"> 
name, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
defaultValue, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
minValue, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
maxValue)<br>
</font>Scenario Parameters are values that can be adjusted by the player before 
staring a game.&nbsp; They each have a name, a default value, and a minimum and 
maximum.&nbsp; If you want to provide Scenario Parameters in your Scenario, use 
the CreateParameter method in your Scenario class' constructor.&nbsp; Save the 
resulting ScenarioParameter values as private variables.&nbsp; In your 
BuildScenario code, when you want to access the values of a Scenario Parameter, 
use the Value property of the ScenarioParameter object that you created and 
saved in the constructor.</p>
<p>See the Classic.cs Scenario for an example of a Scenario that creates and 
uses Scenario Parameters.</p>
<p><b><font SIZE="2" color="#FFFF00">The Game Property</font></b></p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> SVGame</font><font SIZE="2"> Game</p>
</font>
<p>This property returns an instance of an SVGame 
class.&nbsp; The SVGame class contains all of the 
internal objects currently created in the game.&nbsp; For example, It contains a List of
<a href="StarShips.htm">StarShip</a> objects called StarShips, a List of
<a href="StarSystems.htm">StarSystem</a> objects called StarSystems, etc.</p>
<p>You can access this property during the BuildScenario method to gain 
information about the current state of the Scenario.&nbsp; During BuildScenario, 
you are also free to change information in the game state using properties in 
the SVGame class.&nbsp; For example, you can directly set the Values of 
StarSystems, assign Cargo to StarShips, or even change StarSystem Names.</p>
<p>You will also need to access game information during the VictoryReached 
method, if you are providing your own Victory Conditions to the Scenario.&nbsp; 
Again, do not MODIFY information from within VictoryReached, because changes 
made there will not get communicated to other players in a MultiPlayer game.</p>
<p>You can also access information from this property during the ProcessImpulse 
method, described below.&nbsp; However, do not CHANGE information during 
ProcessImpulse.&nbsp; Changes here are not communicated to other players in a 
MultiPlayer game.&nbsp; To make dynamic changes, use the methods of the 
DynamicEvents property, described next.</p>
<p>The best way to learn about what's in the SVGame 
class is to explore its properties and methods with Intellisense from Visual 
Studio, all of the information is fairly self-documenting.&nbsp; If you have 
questions please post them on the
<a href="http://www.siliconcommandergames.com/">Silicon Commander Games</a> 
message board.</p>
<p><font color="#FFFF00"><b>The DynamicEvents property</b></font></p>
<p>This property allows you to call methods that produce changes inside the game 
that are communicated to other players in a MultiPlayer game.&nbsp; It is your 
window to producing exciting, dynamic Scenarios for Solar Vengeance.&nbsp; It's 
use is documented in the <a href="Dynamic%20Scenarios.htm">Dynamic Scenarios</a> 
topic.</p>
<p><font color="#FFFF00"><b>PaintHooks</b></font></p>
<p>PaintHooks allow you to render your own graphics to the game map during a 
game.&nbsp; They are described in detail in the <a href="PaintHooks.htm">
PaintHooks</a> topic.</p>
<p><b><font color="#FFFF00">How to Install your Scenario</font></b></p>
<p>Making your Scenario available to Solar Vengeance 5 could not be easier.&nbsp; 
Simply copy or move the .cs source code file of your Scenario into the 
&quot;Scenarios&quot; folder under SV5's main installation folder.&nbsp; The next time you 
start SV5, your brand new Scenario will be available in the Scenarios list, 
complete with an automatically generated preview image.</p>
</font>

</body>

</html>